package org.witsoft.demo.graphql.resovler;


import graphql.kickstart.tools.GraphQLQueryResolver;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
import org.witsoft.demo.graphql.entity.User;
import org.witsoft.demo.graphql.model.Result;
import org.witsoft.demo.graphql.model.UserInput;
import org.witsoft.demo.graphql.service.UserService;

@Component
@RequiredArgsConstructor
public class UserQuery {

   private final UserService userService;

    public Result<User> login(String email, String pwd){
        User user = userService.verify(email, pwd);
        if(user == null){
            return Result.error("用户名或密码错误");
        }
        return Result.success(user);
    }

    public Result<User> save(UserInput input){
        User user = userService.save(input);
        return Result.success(user);
    }


}
